package cn.shengchao.examstar.knowledge.infrastructure.converter;

import cn.shengchao.examstar.knowledge.domain.entity.KnowledgePoint;
import cn.shengchao.examstar.knowledge.infrastructure.dao.po.TKnowledgePointTree;
import org.springframework.stereotype.Component;

/**
 * 知识点实体转换器
 */
@Component
public class KnowledgePointConverter {

    /**
     * PO转领域实体
     */
    public KnowledgePoint toEntity(TKnowledgePointTree po) {
        if (po == null) {
            return null;
        }
        
        KnowledgePoint entity = new KnowledgePoint();
        entity.setId(po.getId());
        entity.setSpecificationTypeId(po.getSpecificationTypeId());
        entity.setName(po.getName());
        entity.setStatus(po.getStatus());
        entity.setParentId(po.getParentId());
        entity.setPath(po.getPath());
        entity.setSort(po.getSort());
        entity.setKeyPoints(po.getKeyPoints());
        entity.setCoreConcept(po.getCoreConcept());
        entity.setLearningSuggestions(po.getLearningSuggestions());
        return entity;
    }
    
    /**
     * 领域实体转PO
     */
    public TKnowledgePointTree toPO(KnowledgePoint entity) {
        if (entity == null) {
            return null;
        }
        
        TKnowledgePointTree po = new TKnowledgePointTree();
        po.setId(entity.getId());
        po.setSpecificationTypeId(entity.getSpecificationTypeId());
        po.setName(entity.getName());
        po.setStatus(entity.getStatus());
        po.setParentId(entity.getParentId());
        po.setPath(entity.getPath());
        po.setSort(entity.getSort());
        po.setKeyPoints(entity.getKeyPoints());
        po.setCoreConcept(entity.getCoreConcept());
        po.setLearningSuggestions(entity.getLearningSuggestions());
        return po;
    }
} 